package com.rongxun.common.base;

import android.os.Bundle;

import com.bumptech.glide.Glide;
import com.rongxun.common.R;
import com.rongxun.common.utils.StatusBarUtil;

import javax.annotation.Nullable;

import androidx.appcompat.app.AppCompatActivity;


/**
 * 创建者     庄丰泽
 * 创建时间   2018/5/18 12:56
 * 描述
 */

public abstract class BaseActivity extends AppCompatActivity {

    protected static final String TAG = BaseActivity.class.getSimpleName();

    protected boolean  existActivityWithAnimation = true;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getContentView());
        StatusBarUtil.setStatusBarLightMode(this);
        init();
    }


    @Override
    public void setContentView(int layoutResID) {
        if (layoutResID != 0) {
            super.setContentView(layoutResID);
        }

    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        try {
            Glide.get(this).clearMemory();
        } catch (Exception pE) {
            pE.printStackTrace();
        }
    }


    protected abstract void init();

    protected abstract int getContentView();

    public void onBackPressed() {
        super.onBackPressed();
        if (existActivityWithAnimation) {
            overridePendingTransition(R.anim.slide_in_left, R.anim.side_out_right);
        }
    }
}
